﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace Nhom04_DiaDiemDuLich.DAO
{
    public class DatPhongDAO:DataProvider
    {

        public bool ThemDatPhong(DTO.ThongTinDatPhongDTO ThongTinDatPhongDTO)
        {
            
            

            try
            {
                connect();
                command = new SqlCommand();
                command.Connection = connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "sp_DatPhong";

                paramater = new SqlParameter("MaKH", SqlDbType.Int);
                paramater.Direction = ParameterDirection.Input;
                paramater.Value = ThongTinDatPhongDTO.MaKH;
                command.Parameters.Add(paramater);

                paramater = new SqlParameter("MaPhong", SqlDbType.Int);
                paramater.Direction = ParameterDirection.Input;
                paramater.Value = ThongTinDatPhongDTO.MaPhong;
                command.Parameters.Add(paramater);

                paramater = new SqlParameter("NgayDat", SqlDbType.DateTime);
                paramater.Direction = ParameterDirection.Input;
                paramater.Value = ThongTinDatPhongDTO.NgayDat;
                command.Parameters.Add(paramater);

                paramater = new SqlParameter("SoNguoi", SqlDbType.Int);
                paramater.Direction = ParameterDirection.Input;
                paramater.Value = ThongTinDatPhongDTO.SoNguoi;
                command.Parameters.Add(paramater);

                paramater = new SqlParameter("SoNgayDat", SqlDbType.Int);
                paramater.Direction = ParameterDirection.Input;
                paramater.Value = ThongTinDatPhongDTO.SoNgayDat;
                command.Parameters.Add(paramater);

                paramater = new SqlParameter("NgayNhanPhong", SqlDbType.DateTime);
                paramater.Direction = ParameterDirection.Input;
                paramater.Value = ThongTinDatPhongDTO.NgayNhanPhong;
                command.Parameters.Add(paramater);

                paramater = new SqlParameter("HinhThucThanhToan", SqlDbType.NVarChar);
                paramater.Direction = ParameterDirection.Input;
                paramater.Value = ThongTinDatPhongDTO.HinhThucThanhToan;
                command.Parameters.Add(paramater);

                command.ExecuteNonQuery();
                return true;
            }
            catch(Exception ex)
            {
                return false;
            }
            
            
        }
    }
}
